package poswar.contribute.util;

import java.util.concurrent.Callable;

public class FriendModeManager {
	
	private static boolean friend = false;

	public static void assertFriendAccess() {
		if (!friend) {
			throw new UnsupportedOperationException();
		}
	}
	
	public static synchronized<T> T callInFriendMode(Callable<T> runnable) 
			throws Exception {
		try {
			friend = true;
			
			T thisReturn = runnable.call();
			
			return thisReturn;
		} finally {
			friend = false;
		}
	}
}
